<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.CSACOrder;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.CSACOrder">
		<cfargument name="CSAC_Order_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.CSAC_Order_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new CSACOrder();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				local.loadArgs.Deleted = 0;
				return load(argumentCollection = local.loadArgs);
			} else {
				return new CSACOrder();
			}
		</cfscript>
	</cffunction>

	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.CSACOrder" hint="Overwrites obj properties with provided arguments and returns updated obj">
		<cfargument name="obj" type="assets.calgrants.com.bo.CSACOrder" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			/*************************************
				WMS.CSAC_Order properties
			*************************************/
			if (IsDefined("arguments.CSAC_Order_ID")) {
				local.obj.setCSAC_Order_ID(arguments.CSAC_Order_ID);
			}
			if (IsDefined("arguments.Program_Year")) {
				local.obj.setProgram_Year(arguments.Program_Year);
			}
			if (IsDefined("arguments.Organization_ID")) {
				local.obj.setOrganization_ID(arguments.Organization_ID); 
			}
			if (IsDefined("arguments.Ordered_By_ID")) {
				local.obj.setOrdered_By_ID(arguments.Ordered_By_ID); 
			}
			if (IsDefined("arguments.Workshop_IDs")) {
				local.obj.setWorkshop_IDs(arguments.Workshop_IDs);
			}
			if (IsDefined("arguments.Unique_Volunteers")) {
				local.obj.setUnique_Volunteers(arguments.Unique_Volunteers);
			}
			/*************************************
				CSAC.Order properties
			*************************************/
			if (IsDefined("arguments.Order_ID")) {
				local.obj.setOrder_ID(arguments.Order_ID);
			}
			if (IsDefined("arguments.Order_UID")) {
				local.obj.setOrder_UID(arguments.Order_UID);
			}
			if (IsDefined("arguments.Approved_By_ID")) {
				local.obj.setApproved_By_ID(arguments.Approved_By_ID); 
			}
			if (IsDefined("arguments.Shipped_By_ID")) {
				local.obj.setShipped_By_ID(arguments.Shipped_By_ID); 
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted); 
			}
			if (IsDefined("arguments.Status")) {
				local.obj.setStatus(arguments.Status); 
			}
			if (IsDefined("arguments.Order_Date")) {
				local.obj.setOrder_Date(arguments.Order_Date); 
			}
			if (IsDefined("arguments.Approved_Date")) {
				local.obj.setApproved_Date(arguments.Approved_Date); 
			}
			if (IsDefined("arguments.Shipped_Date")) {
				local.obj.setShipped_Date(arguments.Shipped_Date); 
			}
			if (IsDefined("arguments.Shipping_Instructions")) {
				local.obj.setShipping_Instructions(arguments.Shipping_Instructions);
			}
			if (IsDefined("arguments.Institution_ID")) {
				local.obj.setInstitution_ID(arguments.Institution_ID); 
			}
			if (IsDefined("arguments.Institution_Type")) {
				local.obj.setInstitution_Type(arguments.Institution_Type); 
			}
			if (IsDefined("arguments.Institution")) {
				local.obj.setInstitution(arguments.Institution); 
			}
			if (IsDefined("arguments.Department")) {
				local.obj.setDepartment(arguments.Department); 
			}
			if (IsDefined("arguments.Address1")) {                             
				local.obj.setAddress1(arguments.Address1);
			}
			if (IsDefined("arguments.Address2")) {                             
				local.obj.setAddress2(arguments.Address2);
			}
			if (IsDefined("arguments.City")) {
				local.obj.setCity(arguments.City);
			}
			if (IsDefined("arguments.State")) {
				local.obj.setState(arguments.State);
			}
			if (IsDefined("arguments.Zip_Code")) {
				local.obj.setZip_Code(arguments.Zip_Code);
			}
			if (IsDefined("arguments.First_Name")) {
				local.obj.setFirst_Name(arguments.First_Name); 
			}
			if (IsDefined("arguments.Last_Name")) {
				local.obj.setLast_Name(arguments.Last_Name); 
			}
			if (IsDefined("arguments.Email")) {
				local.obj.setEmail(arguments.Email); 
			}
			if (IsDefined("arguments.Phone")) {
				local.obj.setPhone(arguments.Phone); 
			}
			if (IsDefined("arguments.Extension")) {
				local.obj.setExtension(arguments.Extension); 
			}
			if (IsDefined("arguments.Shared_Notes")) {
				local.obj.setShared_Notes(arguments.Shared_Notes);
			}
			if (IsDefined("arguments.Private_Notes")) {
				local.obj.setPrivate_Notes(arguments.Private_Notes);
			}
			if (IsDefined("arguments.WMS_Order_ID")) {
				local.obj.setWMS_Order_ID(arguments.WMS_Order_ID);
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}	
			return local.obj;
		</cfscript>
	</cffunction>
	
	<cffunction name="read" access="public" output="false" returntype="any">
		<!--- WMS.CSAC_Order properties --->
		<cfargument name="CSAC_Order_ID" required="false" default="" />
		<cfargument name="Program_Year" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Organization_ID" required="false" default="" />
		<cfargument name="Ordered_By_ID" required="false" default="" />
		<cfargument name="Workshop_IDs" required="false" default="" />
		<cfargument name="Unique_Volunteers" required="false" default="" />
		<!--- CSAC.Order properties --->
		<cfargument name="Order_ID" required="false" default="" />
		<cfargument name="Order_UID" required="false" default="" />
		<cfargument name="Approved_By_ID" required="false" default="" />
		<cfargument name="Shipped_By_ID" required="false" default="" />
		<cfargument name="Status" required="false" default="" />
		<cfargument name="Order_Date" required="false" default="" />
		<cfargument name="Approved_Date" required="false" default="" />
		<cfargument name="Shipped_Date" required="false" default="" />
		<cfargument name="Shipping_Instructions" required="false" default="" />
		<cfargument name="Institution_ID" required="false" default="" />
		<cfargument name="Institution_Type" required="false" default="" />
		<cfargument name="Institution" required="false" default="" />
		<cfargument name="Department" required="false" default="" />
		<cfargument name="Address1" required="false" default="" />
		<cfargument name="Address2" required="false" default="" />
		<cfargument name="City" required="false" default="" />
		<cfargument name="State" required="false" default="" />
		<cfargument name="Zip_Code" required="false" default="" />
		<cfargument name="First_Name" required="false" default="" />
		<cfargument name="Last_Name" required="false" default="" />
		<cfargument name="Email" required="false" default="" />
		<cfargument name="Phone" required="false" default="" />
		<cfargument name="Extension" required="false" default="" />
		<cfargument name="Shared_Notes" required="false" default="" />
		<cfargument name="Private_Notes" required="false" default="" />
		<cfargument name="WMS_Order_ID" required="false" default="" hint="Same as WMS.CSAC_Order_ID" />	
		<cfargument name="Date_Created" required="false" default="" />
		<!--- filters --->
		<!--- WMS --->
		<cfargument name="programYears" required="false" default="" />
		<cfargument name="csacOrderIDs" required="false" default="" />
		<cfargument name="organizationIDs" required="false" default="" />
		<cfargument name="orderedByIDs" required="false" default="" />
		<cfargument name="regionIDs" required="false" default="" />
		<!--- CSAC --->
		<cfargument name="statuses" required="false" default="" />
		<cfargument name="fromOrderDate" required="false" default="" />
		<cfargument name="toOrderDate" required="false" default="" />
		<cfargument name="fromApprovedDate" required="false" default="" />
		<cfargument name="toApprovedDate" required="false" default="" />
		<cfargument name="institutionTypes" required="false" default="" />
		<cfargument name="orderIDs" required="false" default="" />
		<cfargument name="approverIDs" required="false" default="" />
		<cfargument name="institutionIDs" required="false" default="" />
		<cfargument name="wmsOrderIDs" required="false" default="" hint="Same as csacOrderIDs" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readCSACOrder">
			<!--- WMS --->
			<cfprocparam value="#arguments.CSAC_Order_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.CSAC_Order_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Program_Year#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Program_Year)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Organization_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Organization_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Ordered_By_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Ordered_By_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Workshop_IDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Workshop_IDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Unique_Volunteers#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Unique_Volunteers)) eq 0, true, false)#" />
			<!--- CSAC --->
			<cfprocparam value="#arguments.Order_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Order_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Order_UID#" cfsqltype="CF_SQL_IDSTAMP" null="true" />
			<cfprocparam value="#arguments.Approved_By_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Approved_By_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shipped_By_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Shipped_By_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Status#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Status)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Order_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Order_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Approved_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Approved_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shipped_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Shipped_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shipping_Instructions#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Shipping_Instructions)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Institution_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution_Type#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Institution_Type)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Institution)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Department#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Department)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address1#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address1)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address2#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address2)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.City#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.City)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.State#" cfsqltype="CF_SQL_CHAR" null="#IIf(Len(Trim(arguments.State)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Zip_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Zip_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.First_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.First_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Last_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Last_Name)) eq 0, true, false)#" />
			<cfprocparam value="#LCase(arguments.Email)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Email)) eq 0, true, false)#" />
			<cfprocparam value="#formatPhone(arguments.Phone)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Phone)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Extension#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Extension)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shared_Notes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Shared_Notes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Private_Notes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Private_Notes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.WMS_Order_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.WMS_Order_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<!--- Filters --->
			<!--- WMS --->
			<cfprocparam value="#arguments.programYears#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.programYears)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.csacOrderIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.csacOrderIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.organizationIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.organizationIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.orderedByIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.orderedByIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.regionIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.regionIDs)) eq 0, true, false)#" />
			<!--- CSAC --->
			<cfprocparam value="#arguments.statuses#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.statuses)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.fromOrderDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.fromOrderDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.toOrderDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.toOrderDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.fromApprovedDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.fromApprovedDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.toApprovedDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.toApprovedDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.institutionTypes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.institutionTypes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.orderIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.orderIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.approverIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.approverIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.institutionIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.institutionIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.wmsOrderIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.wmsOrderIDs)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>
	
	<!--- <cffunction name="read" access="public" output="false" returntype="any">
		<!--- <cfargument name="CSAC_Order_ID" required="false" default="" />
		<cfargument name="Program_Year" required="false" default="" />
		<cfargument name="Approved" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Organization_ID" required="false" default="" />
		<cfargument name="Ordered_By_ID" required="false" default="" />
		<cfargument name="Anticipated_Ship_Date" required="false" default="" />
		<cfargument name="Fulfillment_Date" required="false" default="" />
		<cfargument name="Student_Count" required="false" default="" />
		<cfargument name="Volunteer_Count" required="false" default="" />
		<cfargument name="Order_Value_IDs" required="false" default="" />
		<cfargument name="Quantities" required="false" default="" />
		<cfargument name="Shipping_Organization" required="false" default="" />
		<cfargument name="Shipping_Department" required="false" default="" />
		<cfargument name="Shipping_Name" required="false" default="" />
		<cfargument name="Shipping_Address" required="false" default="" />
		<cfargument name="Shipping_City" required="false" default="" />
		<cfargument name="Shipping_State" required="false" default="" />
		<cfargument name="Shipping_Zip_Code" required="false" default="" />
		<cfargument name="Shipping_Phone" required="false" default="" />
		<cfargument name="Shipping_Instructions" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />
		<cfargument name="organizationIDs" required="false" default="" />
		<cfargument name="regionIDs" required="false" default="" /> --->
		<!--- <cfargument name="CSAC_Order_ID" required="false" default="" hint="CSAC_Order_ID" />
		<cfargument name="Program_Year" required="false" default="" hint="fromOrderDate, toOrderDate" />
		<cfargument name="Approved" required="false" default="" hint="Status" />
		<cfargument name="Deleted" required="false" default="0" hint="Deleted" />
		<cfargument name="Organization_ID" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="Ordered_By_ID" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="Anticipated_Ship_Date" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="Fulfillment_Date" required="false" default="" hint="Order_Date" />
		<cfargument name="Student_Count" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="Volunteer_Count" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="Order_Value_IDs" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="Quantities" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="Shipping_Organization" required="false" default="" hint="Institution" />
		<cfargument name="Shipping_Department" required="false" default="" hint="Department" />
		<cfargument name="Shipping_Name" required="false" default="" hint="First_Name Last_Name" />
		<cfargument name="Shipping_Address" required="false" default="" hint="Address1" />
		<cfargument name="Shipping_City" required="false" default="" hint="City" />
		<cfargument name="Shipping_State" required="false" default="" hint="State" />
		<cfargument name="Shipping_Zip_Code" required="false" default="" hint="Zip_Code" />
		<cfargument name="Shipping_Phone" required="false" default="" hint="Phone" />
		<cfargument name="Shipping_Instructions" required="false" default="" hint="Shipping Instructions" />
		<cfargument name="Date_Created" required="false" default="" hint="Date_Created" />
		<cfargument name="statuses" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="organizationIDs" required="false" default="" hint="**************************************************undefined" />
		<cfargument name="regionIDs" required="false" default="" hint="**************************************************undefined" /> --->
		
		<cfset local.CSAC_Order_ID = "">
		<cfset local.Order_UID = "">
		<cfset local.Approved_By_ID = "">
		<cfset local.Deleted = "" />
		<cfset local.Status = "">
		<cfset local.Order_Date = "">
		<cfset local.Approved_Date = "">
		<cfset local.Shipping_Instructions = "">
		<cfset local.Institution_ID = "">
		<cfset local.Institution_Type = "">
		<cfset local.Institution = "">
		<cfset local.Department = "">
		<cfset local.Address1 = "">
		<cfset local.Address2 = "">
		<cfset local.City = "">
		<cfset local.State = "">
		<cfset local.Zip_Code = "">
		<cfset local.First_Name = "">
		<cfset local.Last_Name = "">
		<cfset local.Email = "">
		<cfset local.Phone = "">
		<cfset local.Extension = "">
		<cfset local.Shared_Notes = "">
		<cfset local.Private_Notes = "">
		<cfset local.Source = "">
		<cfset local.Source_ID = "">
		<cfset local.Source_User_ID = "">	
		<cfset local.Date_Created = "">
		<cfset local.orderIDs = "">
		<cfset local.approverIDs = "">
		<cfset local.institutionIDs = "">
		<cfset local.statuses = "">
		<cfset local.fromOrderDate = "" >
		<cfset local.toOrderDate = "">
		<cfset local.fromApprovedDate = "">
		<cfset local.toApprovedDate = "">
		<cfset local.institutionTypes = "">
		<cfset local.sources = "">
		<cfset local.sourceIDs = "">
		<cfset local.sourceUserIDs = "">
		<cfset local.regionIDs = "">
		<cfset var recs = "">
		
		<cfset local.Source = "CCFC" />
		<cfset local.Deleted = 0 />
		
		<cfif Len(Trim(arguments.CSAC_Order_ID)) gt 0>
			<cfset local.CSAC_Order_ID = arguments.CSAC_Order_ID />
		</cfif>
		<cfif Len(Trim(arguments.Program_Year)) gt 0>
			<cfset local.fromOrderDate = CreateDate(ListFirst(arguments.Program_Year, "-"), 9, 1) />
			<cfset local.toOrderDate = CreateDate(ListLast(arguments.Program_Year, "-"), 8, 30) />
		</cfif>
		<cfif Len(Trim(arguments.statuses)) gt 0>
			<cfset local.statuses = arguments.statuses />
		</cfif>
		<cfif Len(Trim(arguments.organizationIDs)) gt 0>
			<cfset local.sourceIDs = arguments.organizationIDs />
		</cfif>
		<cfif Len(Trim(arguments.regionIDs)) gt 0>
			<cfset local.regionIDs = arguments.regionIDs />
		</cfif>
		<!--- call order database instead of WMS --->
		<cfstoredproc datasource="#getOrderDatasource()#" procedure="readOrder">
			<cfprocparam value="#arguments.CSAC_Order_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.CSAC_Order_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Order_UID#" cfsqltype="CF_SQL_IDSTAMP" null="#IIf(Len(Trim(arguments.Order_UID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Approved_By_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Approved_By_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Status#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Status)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Order_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Order_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Approved_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Approved_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shipping_Instructions#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Shipping_Instructions)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Institution_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution_Type#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Institution_Type)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Institution)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Department#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Department)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address1#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address1)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address2#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address2)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.City#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.City)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.State#" cfsqltype="CF_SQL_CHAR" null="#IIf(Len(Trim(arguments.State)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Zip_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Zip_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.First_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.First_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Last_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Last_Name)) eq 0, true, false)#" />
			<cfprocparam value="#LCase(arguments.Email)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Email)) eq 0, true, false)#" />
			<cfprocparam value="#formatPhone(arguments.Phone)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Phone)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Extension#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Extension)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shared_Notes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Shared_Notes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Private_Notes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Private_Notes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Source#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Source)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Source_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Source_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Source_User_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Source_User_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.orderIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.orderIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.approverIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.approverIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.institutionIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.institutionIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.statuses#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.statuses)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.fromOrderDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.fromOrderDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.toOrderDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.toOrderDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.fromApprovedDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.fromApprovedDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.toApprovedDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.toApprovedDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.institutionTypes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.institutionTypes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.sources#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.sources)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.sourceIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.sourceIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.sourceUserIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.sourceUserIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.regionIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.regionIDs)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction> --->

	<!--- <cffunction name="csac_read" access="public" output="false" returntype="any">
		<cfargument name="CSAC_Order_ID" required="false" default="" />
		<cfargument name="Order_UID" required="false" default="" />
		<cfargument name="Approved_By_ID" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Status" required="false" default="" />
		<cfargument name="Order_Date" required="false" default="" />
		<cfargument name="Approved_Date" required="false" default="" />
		<cfargument name="Shipping_Instructions" required="false" default="" />
		<cfargument name="Institution_ID" required="false" default="" />
		<cfargument name="Institution_Type" required="false" default="" />
		<cfargument name="Institution" required="false" default="" />
		<cfargument name="Department" required="false" default="" />
		<cfargument name="Address1" required="false" default="" />
		<cfargument name="Address2" required="false" default="" />
		<cfargument name="City" required="false" default="" />
		<cfargument name="State" required="false" default="" />
		<cfargument name="Zip_Code" required="false" default="" />
		<cfargument name="First_Name" required="false" default="" />
		<cfargument name="Last_Name" required="false" default="" />
		<cfargument name="Email" required="false" default="" />
		<cfargument name="Phone" required="false" default="" />
		<cfargument name="Extension" required="false" default="" />
		<cfargument name="Shared_Notes" required="false" default="" />
		<cfargument name="Private_Notes" required="false" default="" />		
		<cfargument name="Date_Created" required="false" default="" />
		<cfargument name="orderIDs" required="false" default="" />
		<cfargument name="approverIDs" required="false" default="" />
		<cfargument name="institutionIDs" required="false" default="" />
		<cfargument name="statuses" required="false" default="" />
		<cfargument name="fromOrderDate" required="false" default="" />
		<cfargument name="toOrderDate" required="false" default="" />
		<cfargument name="fromApprovedDate" required="false" default="" />
		<cfargument name="toApprovedDate" required="false" default="" />
		<cfargument name="institutionTypes" required="false" default="" />
		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readOrder">
			<cfprocparam value="#arguments.CSAC_Order_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.CSAC_Order_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Order_UID#" cfsqltype="CF_SQL_IDSTAMP" null="#IIf(Len(Trim(arguments.Order_UID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Approved_By_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Approved_By_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Status#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Status)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Order_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Order_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Approved_Date#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.Approved_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shipping_Instructions#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Shipping_Instructions)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Institution_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution_Type#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Institution_Type)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Institution)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Department#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Department)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address1#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address1)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Address2#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Address2)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.City#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.City)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.State#" cfsqltype="CF_SQL_CHAR" null="#IIf(Len(Trim(arguments.State)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Zip_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Zip_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.First_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.First_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Last_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Last_Name)) eq 0, true, false)#" />
			<cfprocparam value="#LCase(arguments.Email)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Email)) eq 0, true, false)#" />
			<cfprocparam value="#formatPhone(arguments.Phone)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Phone)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Extension#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Extension)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Shared_Notes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Shared_Notes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Private_Notes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Private_Notes)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.orderIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.orderIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.approverIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.approverIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.institutionIDs#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.institutionIDs)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.statuses#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.statuses)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.fromOrderDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.fromOrderDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.toOrderDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.toOrderDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.fromApprovedDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.fromApprovedDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.toApprovedDate#" cfsqltype="CF_SQL_DATE" null="#IIf(Len(Trim(arguments.toApprovedDate)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.institutionTypes#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.institutionTypes)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction> --->

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="csacOrder" required="true" type="assets.calgrants.com.bo.CSACOrder" />
		<cfstoredproc datasource="#getDatasource()#" procedure="saveCSACOrder">
			<cfprocparam value="#csacOrder.getCSAC_Order_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#csacOrder.getProgram_Year()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#csacOrder.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#csacOrder.getOrganization_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#csacOrder.getOrdered_By_ID()#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="#csacOrder.getWorkshop_IDs()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(csacOrder.getWorkshop_IDs())) eq 0, true, false)#" />
			<cfprocparam value="#csacOrder.getUnique_Volunteers()#" cfsqltype="CF_SQL_INTEGER" null="false" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="CSAC_Order_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyCSACOrder">
			<cfprocparam value="#arguments.CSAC_Order_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

